<ul class="layui-nav layui-layout-right">
    <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
        <a href="javascript:;">
            <img src="/media/projects/images/CaiXiaoLin.jpg" class="layui-nav-img">
            <span id="userNameSpan"></span>
        </a>
        <dl class="layui-nav-child">
            <dd><a href="javascript:;">
                积分
                <span id="userScoreSpan" class="layui-font-green layui-font-18"></span>
            </a></dd>
            <dd onclick="upload_user_data()"><a href="javascript:;">更新用户数据(浅)</a></dd>
            <dd onclick="logout()"><a href="javascript:;">退出登录</a></dd>
        </dl>
    </li>
  
</ul>

<script>
    document.querySelector("#userNameSpan").textContent = window.userInfo.username;
    document.querySelector("#userScoreSpan").textContent = window.userInfo.points;
    BloodSpiderFunction_updateUserInfoLocalStorage()
    function upload_user_data() {
        BloodSpiderFunction_updateUserInfoLocalStorage({
            BS_ShowLoading: true,
            successCallback: (res) => {
                // 提示用户更新成功
                showToast('用户数据更新成功', 'success');
            },
            errorCallback: (error) => {
                // 提示用户更新失败
                showToast('用户数据更新失败：' + error.message);
            },
        })
    }
    function logout() {
        // 清楚本地的全部数据,包括session、cookie
        localStorage.clear();
        sessionStorage.clear();
        // 刷新页面
        window.location.href = "/web/index/";
    }
</script>